<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="../mastertemplate/MasterPage.xhtml" xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:syn="http://www.syniverse.com">
	<ui:define name="left">
	</ui:define>
	<ui:define name="right">
	</ui:define>
	<ui:define name="content">
		<p:panel header="#{msg.audit_title}">
			<h:form>
				<p:dialog id="helpDialogid" widgetVar="helpDialog" header="#{msg.general_help_header}" style="min-width:400px">
					<p:panelGrid columns="2" style="max-width:600px">
						<h:outputText value="#{msg.general_help_details}:"/>
						<h:outputText value="#{msg.audit_function}" style="max-width:600px" escape="false"/>
						<h:outputText value="#{msg.audit_columndes}:" />
						<p:panelGrid columns="2" style="min-width:500px">
						<h:outputText value="#{msg.audit_actionee_name}:" style="min-width:100px"/>
						<h:outputText value="#{msg.audit_actionee_name_des}" />
						<h:outputText value="#{msg.audit_actionee_ip}:" />
						<h:outputText value="#{msg.audit_actionee_ip_des}" />
						<h:outputText value="#{msg.audit_screen_id}:" />
						<h:outputText value="#{msg.audit_screen_id_des}" />
						<h:outputText value="#{msg.audit_object}:" />
						<h:outputText value="#{msg.audit_object_des}" />
						</p:panelGrid>
					</p:panelGrid>
				</p:dialog>
				<p:overlayPanel id="helpPanel" for="helpLink" showEvent="mouseover" hideEvent="mouseout">
						<h:outputText value="#{msg.audit_help}" escape="false"/>
				</p:overlayPanel>
				<f:facet name="actions">  
		           	<p:commandLink id="helpLink" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default" onclick="helpDialog.show()">  
			    	    <h:outputText styleClass="ui-icon ui-icon-help" />  
		           	</p:commandLink>    
	        	</f:facet>
	        	</h:form>
				<h:form id="searchForm">
					<p:growl id="messages" />
					<h:panelGroup style="float: right">	
						<p:commandButton id="clear" update=":searchForm:searchField" icon="ui-icon ui-icon-close"
							actionListener="#{AuditBean.clear}" />
						<p:commandButton id="search" update="@form :dataForm" icon="ui-icon-search"
							actionListener="#{AuditBean.listenSearch}" />
						<p:tooltip for="search" value="#{msg.general_search_tooltip}"/>
						<p:tooltip for="clear" value="#{msg.general_clear_tooltip}"/>	
					</h:panelGroup>
					<h:panelGrid id="searchField" columns="8" cellpadding="2">
						<h:outputText value="#{msg.audit_from_date}:" styleClass="listTag"/>
						<p:calendar value="#{AuditBean.fromDate}" pattern="yyyy-MM-dd HH:mm:ss" label="#{msg.audit_from_date}" showButtonPanel="true">
							<syn:convertTimestamp pattern="yyyy-MM-dd HH:mm:ss" />
						</p:calendar>
						<h:outputText value="#{msg.audit_to_date}:" styleClass="listTag"/>
						<p:calendar value="#{AuditBean.toDate}" pattern="yyyy-MM-dd HH:mm:ss" label="#{msg.audit_to_date}" showButtonPanel="true">
							<syn:convertTimestamp pattern="yyyy-MM-dd HH:mm:ss" />
						</p:calendar>
						<h:outputText value="#{msg.audit_actionee_name}:" styleClass="listTag"/>
						<p:inputText value="#{AuditBean.actioneeName}" label="#{msg.audit_actionee_name}"/>
						<h:outputText value="#{msg.audit_actionee_ip}:" styleClass="listTag"/>
						<p:inputText value="#{AuditBean.actioneeIp}" label="#{msg.audit_actionee_ip}"/>
						<h:outputText value="#{msg.audit_screen_id}:" styleClass="listTag"/>
						<h:selectOneMenu value="#{AuditBean.screenId}" label="#{msg.audit_screen_id}" style="width:100%">
							<f:selectItems value="#{AppType.screenIdOptions}" />
						</h:selectOneMenu>
						
						<h:outputText value="#{msg.audit_category}:" styleClass="listTag"/>
						<h:selectOneMenu value="#{AuditBean.actionCategory}" label="#{msg.audit_category}" style="width:100%">
							<f:selectItems value="#{AppType.actionCategoryOptions}" />
						</h:selectOneMenu>
						<h:outputText value="#{msg.audit_type}:" styleClass="listTag"/>
						<h:selectOneMenu value="#{AuditBean.actionType}" label="#{msg.audit_type}" style="width:100%">
							<f:selectItems value="#{AppType.actionTypeOptions}" />
						</h:selectOneMenu>
						<h:outputText value="#{msg.audit_result}:" styleClass="listTag"/>
						<h:selectOneMenu value="#{AuditBean.result}" label="#{msg.audit_result}" style="width:100%">
							<f:selectItems value="#{AppType.resultOptions}" />
						</h:selectOneMenu>
						<h:outputText value="#{msg.audit_object}:" styleClass="listTag"/>
						<h:selectOneMenu value="#{AuditBean.object}" label="#{msg.audit_object}" style="width:100%">
							<f:selectItems value="#{AppType.objectOptions}" />
						</h:selectOneMenu>
						<h:outputText value="#{msg.audit_objectid}:" styleClass="listTag"/>
						<p:inputText value="#{AuditBean.objectId}" label="#{msg.audit_objectId}" style="width:95%"/>
					</h:panelGrid>
				</h:form>

				<br />
				<h:form id="dataForm">
					<p:dataTable var="log" value="#{AuditBean.model}" paginator="true" rows="10" paginatorPosition="bottom"
						rowsPerPageTemplate="10,20,50,100" lazy="true" selectionMode="single" selection="#{AuditBean.selectedLog}"
						paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
						<p:ajax event="rowSelect" update=":dataForm:display" oncomplete="detailsDialog.show()" />
						<p:column headerText="#{msg.table_id}" style="min-width:20px;width:5%" >
							<h:outputText value="#{log.id}" />
						</p:column>
						<p:column headerText="#{msg.table_actiontime}" style="min-width:120px;width:10%" sortBy="#{log.actionTime}">
							<h:outputText value="#{log.actionTime}" />
						</p:column>
	
						<p:column headerText="#{msg.table_actioneename}" sortBy="#{log.actioneeName}" style="min-width:100px;width:10%">
							<h:outputText value="#{log.actioneeName}" />
						</p:column>
	
						<p:column headerText="#{msg.table_actioneeip}" style="min-width:100px;width:10%" sortBy="#{log.actioneeIp}">
							<h:outputText value="#{log.actioneeIp}" />
						</p:column>
	
						<p:column headerText="#{msg.table_screenid}" style="min-width:120px;width:15%" sortBy="#{log.screenId}">
							<h:outputText value="#{log.screenId}" />
						</p:column>
	
						<p:column headerText="#{msg.table_actioncategory}" sortBy="#{log.actionCategory}" style="min-width:120px;width:15%">
							<h:outputText value="#{log.actionCategory}" />
						</p:column>
	
						<p:column headerText="#{msg.table_actiontype}" sortBy="#{log.actionType}" style="min-width:100px;width:10%">
							<h:outputText value="#{log.actionType}" />
						</p:column>
						
						<p:column headerText="#{msg.table_result}" sortBy="#{log.result}" style="min-wdith:50px;width:5%">
							<h:outputText value="#{log.result}" style="color:#{log.result == 'SUCCESS' ? 'green' : 'red'}"/>
						</p:column>
						
						<p:column headerText="#{msg.table_object}" sortBy="#{log.object}" style="min-width:100px;width:10%">
							<h:outputText value="#{log.object}" />
						</p:column>
						
						<p:column headerText="#{msg.table_objectid}" sortBy="#{log.objectId}" style="min-width:120px;width:15%">
							<h:outputText value="#{log.objectId}" rendered="#{!empty log.objectId}"/>
							<h:outputText value="-" rendered="#{empty log.objectId}" />
						</p:column>
					</p:dataTable>
					<p:dialog header="#{msg.audit_details}" widgetVar="detailsDialog">
							<h:panelGrid id="display" columns="2" cellpadding="4">
								<h:outputText value="#{msg.audit_id}: " styleClass="listTag"/>
								<h:inputText value="#{AuditBean.selectedLog.id}" disabled="true" style="min-width:300px;width:100%"/>
								
								<h:outputText value="#{msg.audit_type}: " styleClass="listTag"/>
								<h:outputText value="#{AuditBean.selectedLog.actionType}" style="min-width:300px;width:100%"/>
								
								<h:outputText value="#{msg.audit_result}: " styleClass="listTag"/>
								<h:outputText value="#{AuditBean.selectedLog.result}" style="min-width:300px;width:100%"/>
								
								<h:outputText value="#{msg.audit_object}: " styleClass="listTag"/>
								<h:outputText value="#{AuditBean.selectedLog.object}" style="width:300px"/>
								
								<h:outputText value="#{msg.audit_objectid}: " styleClass="listTag"/>
								<h:outputText value="#{AuditBean.selectedLog.objectId}" rendered="#{!empty AuditBean.selectedLog.objectId}" style="width:300px"/>
								<h:outputText value="-" rendered="#{empty AuditBean.selectedLog.objectId}" style="width:300px"/>
								
								<h:outputText value="#{msg.audit_cause}:" rendered="#{!empty AuditBean.selectedLog.cause}" styleClass="listTag"/>
								<h:outputText value="#{AuditBean.selectedLog.cause}" escape="false" rendered="#{!empty AuditBean.selectedLog.cause}" style="max-width:300px"/>
							
								<h:panelGroup rendered="#{!empty AuditBean.selectedLog.originVal}">
									<h:outputText value="#{msg.audit_originVal}:" rendered="#{!AuditBean.isExecute()}" styleClass="listTag"/>
									<h:outputText value="#{msg.audit_operations}:" rendered="#{AuditBean.isExecute()}" styleClass="listTag"/>
								</h:panelGroup>
								<h:outputText value="#{AuditBean.selectedLog.originVal}" rendered="#{!empty AuditBean.selectedLog.originVal}" escape="false" style="width:300px"/>
								
								<h:outputText value="#{msg.audit_newVal}:" rendered="#{!empty AuditBean.selectedLog.newVal}" styleClass="listTag"/>
								<h:outputText value="#{AuditBean.selectedLog.newVal}" rendered="#{!empty AuditBean.selectedLog.newVal}" escape="false" style="width:300px"/>
															
								<h:outputText value="#{msg.audit_noFurtherDetails}" rendered="#{!AuditBean.selectedLog.isFurtherDetails()}"/>
								<h:outputText value="#{msg.audit_lastViewBy}: " rendered="#{AuditBean.selectedLog.isLastViewShow()}" />
								<h:outputText value="#{AuditBean.selectedLog.actioneeName}" rendered="#{AuditBean.selectedLog.isLastViewShow()}" />									
							</h:panelGrid>
					</p:dialog>	
				</h:form>
			</p:panel>
	</ui:define>
</ui:composition>
